<?php

// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');

// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
	'name'=>'My Web Application',
    'theme'=>'desktop',

	// preloading 'log' component
	'preload'=>array('log'),

	// autoloading model and component classes
	'import'=>array(
		'application.models.*',
		'application.components.*',
        'application.helpers.*',
        'application.behaviors.*',
        //'User.models.*',
	),

	'modules'=>array(
		// uncomment the following to enable the Gii tool

		'gii'=>array(
			'class'=>'system.gii.GiiModule',
			'password'=>'12345',
		 	// If removed, Gii defaults to localhost only. Edit carefully to taste.
			'ipFilters'=>array('127.0.0.1','::1'),
		),
        'Business'=>array(),
        'Appointment'=>array(),
        'User'=>array(),

	),

	// application components
	'components'=>array(
		'user'=>array(
            'class' => 'WebUser',
			// enable cookie-based authentication
			'allowAutoLogin'=>true,
		),
		// uncomment the following to enable URLs in path-format

		'urlManager'=>array(
			'urlFormat'=>'path',
			'rules'=>array(
                // REST patterns
                /*array('api/list', 'pattern'=>'api/<model:\w+>', 'verb'=>'GET'),
                array('api/view', 'pattern'=>'api/<model:\w+>/<id:\d+>', 'verb'=>'GET'),
                array('api/update', 'pattern'=>'api/<model:\w+>/<id:\d+>', 'verb'=>'PUT'),
                array('api/delete', 'pattern'=>'api/<model:\w+>/<id:\d+>', 'verb'=>'DELETE'),
                array('api/create', 'pattern'=>'api/<model:\w+>', 'verb'=>'POST'),*/

                array('site/login'         , 'pattern'=>'api/webUser'              , 'verb'=>'POST')   ,
                array('site/login'         , 'pattern'=>'api/webUser'              , 'verb'=>'PUT')   ,
                array('site/logout'        , 'pattern'=>'api/webUser'              , 'verb'=>'DELETE') ,
                array('site/forgotpass'    , 'pattern'=>'api/site/forgotpass'      , 'verb'=>'POST')   ,
                array('site/passreset'     , 'pattern'=>'api/site/passreset'       , 'verb'=>'POST')   ,

                //Service
                array('Business/default/list'    , 'pattern'=>'api/business'          , 'verb'=>'GET'),
                array('Business/default/create'  , 'pattern'=>'api/business'          , 'verb'=>'POST'),
                array('Business/default/view'    , 'pattern'=>'api/business/<id:\d+>' , 'verb'=>'GET'),
                array('Business/default/update'  , 'pattern'=>'api/business/<id:\d+>' , 'verb'=>'PUT'),
                array('Business/default/delete'  , 'pattern'=>'api/business/<id:\d+>' , 'verb'=>'DELETE'),
                //Service
                array('Business/service/makeAppointment'    , 'pattern'=>'business/service'          , 'verb'=>'POST'),

                array('User/default/employee', 'pattern'=>'api/employees'        , 'verb'=>'GET'),
                array('User/default/employeeByService', 'pattern'=>'api/employees/<service_id:\d+>'        , 'verb'=>'GET'),

                array('User/message/thread', 'pattern'=>'api/thread'        , 'verb'=>'GET'),

                array('User/message/inbox'   , 'pattern'=>'api/message'          , 'verb'=>'GET'),
                array('User/message/create'  , 'pattern'=>'api/message'          , 'verb'=>'POST'),

                /*array('Service/default/create'  , 'pattern'=>'api/service'          , 'verb'=>'POST'),
                array('Service/default/view'    , 'pattern'=>'api/service/<id:\d+>' , 'verb'=>'GET'),
                array('Service/default/update'  , 'pattern'=>'api/service/<id:\d+>' , 'verb'=>'PUT'),
                array('Service/default/delete'  , 'pattern'=>'api/service/<id:\d+>' , 'verb'=>'DELETE'),*/

                //Appointment
                array('Appointment/default/list'    , 'pattern'=>'api/appointment'          , 'verb'=>'GET'),
                array('Appointment/default/create'  , 'pattern'=>'api/appointment'          , 'verb'=>'POST'),
                array('Appointment/default/view'    , 'pattern'=>'api/appointment/<id:\d+>' , 'verb'=>'GET'),
                array('Appointment/default/update'  , 'pattern'=>'api/appointment/<id:\d+>' , 'verb'=>'PUT'),
                array('Appointment/default/delete'  , 'pattern'=>'api/appointment/<id:\d+>' , 'verb'=>'DELETE'),

                '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
			),
		),

		/*'db'=>array(
			'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
		),*/
		// uncomment the following to use a MySQL database

		'db'=>array(
			'connectionString' => 'mysql:host=localhost;dbname=eggs',
			'emulatePrepare' => true,
			'username' => 'root',
			'password' => '',
			'charset' => 'utf8',
		),

		'errorHandler'=>array(
			// use 'site/error' action to display errors
            'errorAction'=>'site/error',
        ),

        'session' => array(
            'class' => 'system.web.CDbHttpSession',
            'connectionID' => 'db',
            'autoCreateSessionTable' => true,
            'sessionTableName' => 'yii_session'
        ),
        'cache'=>extension_loaded('apc') ?
            array(
                'class' => 'CApcCache',
            ) :
            array(
                'class' => 'CDbCache',
                'connectionID' => 'db',
                'autoCreateCacheTable' => true,
                'cacheTableName' => 'cache',
            ),

		'log'=>array(
			'class'=>'CLogRouter',
			'routes'=>array(
				array(
					'class'=>'CFileLogRoute',
					'levels'=>'error, warning',
				),
				// uncomment the following to show log messages on web pages
				/*
				array(
					'class'=>'CWebLogRoute',
				),
				*/
			),
		),
	),

	// application-level parameters that can be accessed
	// using Yii::app()->params['paramName']
	'params'=>array(
		// this is used in contact page
		'adminEmail'=>'webmaster@example.com',
	),
);